package cs3343.project.family;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

/**
 * The Class Dice.
 */
public class Dice {
	
	/** The dice img. */
	private JLabel[] diceImg = new JLabel[7]; 
	
	/**
	 * Instantiates a new dice.
	 */
	public Dice() {
		for (int i = 0; i < 7; i++)
			diceImg[i] = new JLabel(new ImageIcon(ConfigManager.IMAGE_PATH + "dice_" + Integer.toString(i) + ".gif"));
	}
	
	/**
	 * Roll dice.
	 *
	 * @param high the high
	 * @param low the low
	 * @return the int
	 */
	public int rollDice(int high, int low) {
		return (int) (Math.random() * (high+1 - low) + low);
	}
	
	/**
	 * Show dice image.
	 *
	 * @param diceNum the dice num
	 */
	public void showDiceImage(int diceNum) {
		for (int i = 0; i < 7; i++)
			diceImg[i].setVisible(false);		
		diceImg[diceNum].setVisible(true);
	}
	
	/**
	 * Hide dice image.
	 *
	 * @param diceNum the dice num
	 */
	public void hideDiceImage(int diceNum) {
		diceImg[diceNum].setVisible(false);
	}

	/**
	 * Gets the dice images.
	 *
	 * @return the dice images
	 */
	public JLabel[] getDiceImages() {
		return diceImg;
	}
	
	/**
	 * Gets the dice image.
	 *
	 * @param diceNum the dice num
	 * @return the dice image
	 */
	public JLabel getDiceImage(int diceNum) {
		return diceImg[diceNum];
	}

	/**
	 * Sets the dice images.
	 *
	 * @param diceImg the new dice images
	 */
	public void setDiceImages(JLabel[] diceImg) {
		this.diceImg = diceImg;
	}
}
